package code._20stream._02createStreamOperation;

import org.junit.Test;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;

public class CreateOperationTest {
    @Test
    public void createSteam1(){
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5,0,-1);
        Stream<Integer> stream = list.stream();
        //返回流中的元素个数
        long count = stream.count();
        System.out.println(count);
    }

    @Test
    public void createSteam2(){
        Integer[] arr={3,2,1};
        Stream<Integer> stream = Arrays.stream(arr);
        long count = stream.count();
        System.out.println(count);
    }

    @Test
    public void createStream3(){
        Stream<Integer> stream = Stream.of(5, 4, 3, 2, 1);
        System.out.println(stream.count());
    }
}
